package product

import (
	"go.uber.org/fx"
	"mallgo/core"
	"mallgo/internal/resources/product/resource"
)

func InitRouter(productResource *resource.ProductResource, s *core.AppServer) {
	// 用户路由
	newProductController := NewProductController(productResource)
	g := s.Engine.Group("/product")
	{
		g.POST("/create", newProductController.Create) // 创建订单
		g.POST("/update", newProductController.Update)
		g.POST("/delete", newProductController.Delete)
		g.POST("/search", newProductController.Search)
		g.POST("/view", newProductController.View)
	}

}

func InitProductCatalogRouter(productResource *resource.ProductCatalogResource, s *core.AppServer) {
	// 用户路由
	newProductController := NewProductCatalogController(productResource)
	g := s.Engine.Group("/productCatalog")
	{
		g.POST("/create", newProductController.Create) // 创建订单
	}

}

var Module = fx.Options(
	fx.Provide(
		resource.NewProductResource,
		resource.NewProductCatalogResource,
		NewProductController,
		NewProductCatalogController,
	),
	fx.Invoke(
		InitRouter,
		InitProductCatalogRouter,
	),
)
